package com.itheima.demo02;

import com.itheima.clientAndService01.Student;

import java.util.ArrayList;
import java.util.Iterator;

public class MainClass04 {
    public static void main(String[] args) {
        Student stu1 = new Student("张三",23);
        Student stu2 = new Student("李四",24);
        Student stu3 = new Student("王五",25);

        ArrayList<Student> list = new ArrayList<>();
        list.add(stu1);
        list.add(stu2);
        list.add(stu3);

        Iterator<Student> it = list.iterator();
        while (it.hasNext()){
            Student student = it.next();
            System.out.println(student);
        }

        System.out.println("--------------------------");

        for (Student student : list) {
            System.out.println(student);
        }
    }
}
